import { get, post, put, del, getWithArgs } from '../utils/xFetch2'
// import axios from 'axios'

const newsAPI = {

    createNew: params => {
        return post('api/v1/news', params)
    },
    getNewsList: params => {
        return getWithArgs('api/v1/news/list', params)
    },
    getNewsDetail: id => {
        return getWithArgs(`api/v1/news/${id}/content`)
    },
    getAllNewsList: params => {
        return getWithArgs('api/v1/news/all', params)
    },
    getNewsListByUser: params => {
        return getWithArgs('api/v1/my/news', params)
    },
    newsDelete: (newsId) => {
        return del(`api/v1/news/${newsId}`)
    },
    newsClose: (newsId) => {
        return put(`api/v1/news/${newsId}/close`)
    },
    newsApprove: (newsId) => {
        return put(`api/v1/news/${newsId}/approve`)
    },
    newsOpen: (newsId) => {
        return put(`api/v1/news/${newsId}/open`)
    }
}

export default newsAPI
